<%@ page language="java" import="java.util.*,com.ncp.model.biz.registerlogin.*" pageEncoding="utf-8"%>
<%@page import="com.ncp.model.entity.registerlogin.UserBasicBean"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
int pageSize=10;//一页显示几条记录
int pageNow=1;//希望显示的页面
int linkNum=10;//表示出现的链接数
//动态接收pageNow
String pagenow=request.getParameter("pageNow");
if(pagenow!=null){
	pageNow=Integer.parseInt(pagenow);	
}
UserManager nm=new UserManager();
ArrayList al=nm.fenYe(pageSize,pageNow);
int pageCount=nm.getPageCount();
System.out.println("pageCount:"+pageCount);
System.out.println("pageNow:"+pageNow);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'news.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body><center>
  <table border="1" align="center">
    	<tr>
    		<td>ID</td>
       		<td>登录名</td>
       		<td>密码</td>
       		<td>级别</td>
       		<td>姓名</td>
       		<td>电子邮件</td>
       		<td>联系电话</td>
       		<td>地址</td>
       		<td>注册时间</td>
       		<td>状态</td>
       		<td>修改用户</td>
       		<td>删除用户</td>
    	</tr>
    	<%
    		for(int i=0;i<al.size();i++){
    			UserBasicBean ubb=(UserBasicBean)al.get(i);
    	 %>
    	 <tr>
    		<td><%=ubb.getUserID() %></td>
    		<td><%=ubb.getUserLoginName() %></td>
    		<td><%=ubb.getPassWord() %></td>
    		<td><%=ubb.getLevelID() %></td>
    		<td><%=ubb.getUserName() %></td>
    		<td><%=ubb.getEmail() %></td>
    		<td><%=ubb.getTel() %></td>
    		<td><%=ubb.getAddress() %></td>
    		<td><%=ubb.getRegisterDate() %></td>
    		<td><%=ubb.getStatus() %></td>
    		<td><a href="UserClServlet?type=del&id=<%=ubb.getUserID()%>" onclick="return window.confirm('您确认要删除该用户吗？')">删除用户</a></td>
    		<td><a href="UserClServlet?type=update&id=<%=ubb.getUserID()%>&loginname=<%=ubb.getUserLoginName() %>&password=<%=ubb.getPassWord() %>&level=<%=ubb.getLevelID() %>&username=<%=ubb.getUserName() %>&email=<%=ubb.getEmail() %>&tel=<%=ubb.getTel() %>&address=<%=ubb.getAddress() %>&date=<%=ubb.getRegisterDate() %>&status=<%=ubb.getStatus() %>">更改状态</a></td>
    	 </tr>
    	 <%
    	 }
    	  %>
    </table>
    <% 
		if(pageNow>1){
			%>
			<a href="UserClServlet?type=fenye&pageNow=1">首页</a>
			<a href="UserClServlet?type=fenye&pageNow=<%=pageNow-1 %>">上一页</a>
			<% 
		}
		if(pageNow<=4){
			for(int i=1;i<=linkNum;i++){
				if(i==pageNow){
					out.println(i+"");
				}else{
					out.println("<a href=UserClServlet?type=fenye&pageNow="+i+">["+i+"]</a>");
				}
			}
		}else if(pageNow>4&&pageNow<pageCount-4){
			for(int i=pageNow-4;i<=pageNow+5;i++){
				if(i==pageNow){
					out.println(i+"");
				}else{
					out.println("<a href=UserClServlet?type=fenye&pageNow="+i+">["+i+"]</a>");
				}
			}
		}else if(pageNow<=pageCount){
			for(int i=pageCount-linkNum+1;i<=pageCount;i++){
				if(i==pageNow){
					out.println(i+"");
				}else{
					out.println("<a href=UserClServlet?type=fenye&pageNow="+i+">["+i+"]</a>");
				}
			}
		}
		if(pageNow<pageCount){
			out.println("<a href=UserClServlet?type=fenye&pageNow="+(pageNow+1)+">下一页</a>");
			out.println("<a href=UserClServlet?type=fenye&pageNow="+pageCount+">尾页</a>");
		}
   %>
  </center></body>
</html>
